package com.karson.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.karson.common.model.SystemMenu;
import com.karson.common.model.SystemRole;
import com.karson.common.model.SystemRoleMenu;
import com.karson.service.dao.SystemMenuMapper;
import com.karson.service.dao.SystemRoleMenuMapper;
import com.karson.service.service.SystemRoleMenuService;
import com.karson.service.service.SystemRoleService;
import com.karson.service.dao.SystemRoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author ZKS
* &#064;description  针对表【ar_system_role(身份管理表)】的数据库操作Service实现
* &#064;createDate  2025-07-04 19:15:17
 */
@Service
public class SystemRoleServiceImpl extends ServiceImpl<SystemRoleMapper, SystemRole>
    implements SystemRoleService{
    @Autowired
    private SystemRoleMapper systemRoleMapper;
    @Autowired
    private SystemMenuMapper systemMenuMapper;
    @Autowired
    private SystemRoleMenuMapper systemRoleMenuMapper;

    @Override
    public List<String> getPremissionList(String roleId) {
        List<String> roles = systemRoleMapper.getRoles(roleId);
        List<SystemMenu> systemMenus = systemMenuMapper.selectBatchIds(roles);
        return systemMenus.stream().map(SystemMenu::getPerms).toList();
    }

    @Override
    public IPage<SystemRole> pageList(IPage<SystemRole> roleIPage) {
        return systemRoleMapper.getRoleList(roleIPage);
    }

    @Override
    public List<Integer> getPremMenuList(Integer id) {
        return systemRoleMenuMapper.getMenuList(id);
    }
}




